package com.xbongbong.saas.model;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.domain.entity.UpdateDataEntity;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;
import com.xbongbong.saas.domain.entity.WorkOrderEntity;
import com.xbongbong.saas.domain.entity.WorkOrderProductEntity;
import com.xbongbong.saas.domain.entity.ext.ProductEntityExt;
import com.xbongbong.saas.enums.UpdateDataTypeEnum;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;
/**
 *
 * @author 魏荣杰
 * @date 2019/3/12 9:56
 * @since v1.0
 * @version v1.0
 */
public interface WorkOrderModel extends IModel<WorkOrderEntity> {

    @Override
    Integer insert(WorkOrderEntity entity) throws XbbException;

    @Override
    Integer update(WorkOrderEntity entity) throws XbbException;

    Integer updateBatchList(List<WorkOrderEntity> workOrderEntityList, String corpid) throws XbbException;

    @Override
    List<WorkOrderEntity> findEntitys(Map<String, Object> param);

    @Override
    Integer getEntitysCount(Map<String, Object> param);

    Integer save(WorkOrderEntity workOrderEntity) throws XbbException;

    WorkOrderEntity getByKey(Long key, String corpid);

    /**
     * Description: 批量删除
     * @param deleteIdIn
     * @param corpid
     * @return java.lang.Integer
     * @throws XbbException XbbException
     * @author 魏荣杰
     * @date 2019/5/9 10:51
     * @since v1.0
     */
    Integer deleteBatch(List<Long> deleteIdIn, String corpid) throws XbbException;

    /**
     * 单个删除
     * @param id
     * @param corpid
     * @return
     * @throws XbbException
     */
    Integer deleteByKey(Long id,String corpid) throws XbbException;
    /**
     * Description: 批量编辑
     * @param updateList
     * @param corpid
     * @return java.lang.Integer
     * @throws XbbException XbbException
     * @author 魏荣杰
     * @date 2019/5/9 19:18
     * @since v1.0
     */
    Integer updateBatch(List<UpdateDataEntity> updateList, String corpid) throws XbbException;

    /**
     * 产品数组中存在null值的数据
     * @param corpid
     * @return
     */
    List<WorkOrderEntity> findNullArrayData(String corpid);

    Integer updateBatch(List<UpdateDataEntity> updateList, String corpid, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    /**
     * 搜索主表数据
     * @param param
     * @return
     */
    @Override
    List<WorkOrderEntity> findEntitysWithoutSub(Map<String, Object> param);

    /**
     * Description: 编辑时格式化解释
     * @param formatExplainDTO
     * @param data
     * @throws XbbException XbbException
     * @author 魏荣杰
     * @date 2019/4/22 10:54
     * @since v1.0
     */
    void formatUpdateExplain(FormatExplainDTO formatExplainDTO, JSONObject data) throws XbbException;

    /**
     * Description: 详情页回显格式化解释
     * @param formDataUpdateGetDTO
     * @param result
     * @throws XbbException XbbException
     * @author 魏荣杰
     * @date 2019/4/19 19:08
     * @since v1.0
     */
    void formatData(SaasAnalysisDataDTO formDataUpdateGetDTO, JSONObject result) throws XbbException;

    void getProductList(String corpid, List<WorkOrderProductEntity> workOrderProductEntities, JSONArray productArray, Map<Long, ProductEntityExt> productMap) throws XbbException;

    JSONObject formatSingleProduct(WorkOrderProductEntity workOrderProductEntity);

    void formatProduct4Show2(Long dataId, String corpid, JSONObject data, UpdateDataTypeEnum updateDataTypeEnum) throws XbbException;

    Integer updateTime(Long id,String corpid) throws XbbException ;
}
